﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace WebApplication.Admins.Controls
{
    public partial class UC_ChuDe : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string searchString = Request.QueryString["Search"] ?? "";
                if (searchString != "")
                    txtTim.Text = searchString;
                Display();
            }
        }
        public void Display()
        {
            repChuDe.DataSource = ChuDeBLL.LayTatCa();
            repChuDe.DataBind();
        }

        protected void btnXoa_Click(object sender, EventArgs e)
        {
            string Id = Request.Form["Id"] ?? "";
            if (Id != "")
            {
                foreach (string id in Id.Split(','))
                    ChuDeBLL.Xoa(id);
                Display();
            }
        }

        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            string searchString = txtTim.Text.ToLower().Trim();
            if (searchString.Length > 0)

                Response.Redirect(LinkBLL.ToSearchChuDe(searchString));


        }
        
    }
}